package com.knowledge.business.controller;

/**
 * @author: zhaoyongke
 * @create: 2025-09-09 11:13
 * @description: ChatController
 */

import com.knowledge.business.domain.ChatRequest;
import com.knowledge.business.domain.ChatResponse;
import com.knowledge.business.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 硅基流动接口
 */

@RestController
@RequestMapping("/api/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;


    /**
     * 创建对话请求（OpenAI）
     */
    @PostMapping("/completions")
    public ChatResponse chatCompletion(@RequestBody ChatRequest request) {
        return chatService.createChatCompletion(
                request.getMessages().get(0).getContent());
    }


}
